package com.xuyiwei.mayi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by xuyiwei on 2019/4/19.
 */
@RestController
public class HelloController {
    @Autowired
    private CacheManager cacheManager;

    @RequestMapping("/setCache")
    public String  setCache(){
        cacheManager.getCache("baseCache").put("name","aa");
        return "缓存放置成功";
    }


    @RequestMapping("/getCache")
    public String  getCache(){
        String cache = cacheManager.getCache("baseCache").get("name",String.class);
        return cache;
    }
}
